/*
 * @Author: Li Zengkun
 * @Date: 2022-09-11 08:51:22
 * @LastEditors: Li Zengkun
 * @LastEditTime: 2022-09-13 22:08:26
 * @Description: 
 */
import { ElMessage } from 'element-plus'

/**
 * @description: 使用 element-plus 的消息提示框
 * @return {*}
 * @param {*} type
 * @param {*} msg
 */
export function useElMessage(type = "success", msg = "success") {
    ElMessage({
        type: type,
        message: msg,
    });
}

/**
 *遍历替换属性名
 * @param arr 省市区集合
 * @return [] 替换属性名结果集
 */
export function eachReplaceKey(arr) {
    let item = [];
    arr.map(list => {
        let newData = {};
        for (let key in list) {
            newData[key] = list[key]
        }
        newData.label = list.name
        if (list.children) {
            newData.children = eachReplaceKey(list.children)

        }
        item.push(newData);
    })
    return item;
}